﻿<%--
This file is part of Ingo Karstein's Web based PowerShell Console for SharePoint project

**Do not remove this comment**

Please see the project homepage at CodePlex:
  http://spwebpsconsole.codeplex.com/
  
The project is based upon my project "Web based PowerShell Console":
  http://webpsconsole.codeplex.com/

Please see my blog:
  http://ikarstein.wordpress.com

Licence: GPLv2
    Ingo Karstein's SharePoint 2010 Custom Ribbon Demo
    Copyright (C) 2011  Ingo Karstein, ikarstein@hotmail.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--%>

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="spwpsc.aspx.cs" Inherits="ik.SharePoint2010.SPWebPSConsole.spwpsc" MasterPageFile="~/_admin/admin.master" %>

<asp:content id="PageHead" contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
    <SharePoint:ScriptLink runat="server" ID="SPWebPSConsoleJQ" LoadAfterUI="true" Localizable="false" OnDemand="false" Name="<%$SPUrl:~SiteCollection/_layouts/ik.SharePoint2010.SPWebPSConsole/jQuery/jquery-1.6.2.min.js%>" />
    <SharePoint:ScriptLink runat="server" ID="SPWebPSConsoleJSJQUI" LoadAfterUI="true" Localizable="false" OnDemand="false" Name="<%$SPUrl:~SiteCollection/_layouts/ik.SharePoint2010.SPWebPSConsole/jQuery/jquery-ui-1.8.15.custom.min.js%>" />
    <SharePoint:ScriptLink runat="server" ID="SPWebPSConsoleJQJSON" LoadAfterUI="true" Localizable="false" OnDemand="false" Name="<%$SPUrl:~SiteCollection/_layouts/ik.SharePoint2010.SPWebPSConsole/jQuery/jquery.json-2.2.min.js%>" />
    <SharePoint:ScriptLink runat="server" ID="SPWebPSConsoleJQDD" LoadAfterUI="true" Localizable="false" OnDemand="false" Name="<%$SPUrl:~SiteCollection/_layouts/ik.SharePoint2010.SPWebPSConsole/jQuery/jquery.dragndrop.min.js%>" />
    <SharePoint:ScriptLink runat="server" ID="SPWebPSConsoleJQMSG" LoadAfterUI="true" Localizable="false" OnDemand="false" Name="<%$SPUrl:~SiteCollection/_layouts/ik.SharePoint2010.SPWebPSConsole/jQuery/jquery.msgbox.js%>" />
    <SharePoint:ScriptLink runat="server" ID="SPWebPSConsoleJS" LoadAfterUI="true" Localizable="false" OnDemand="false" Name="<%$SPUrl:~SiteCollection/_layouts/ik.SharePoint2010.SPWebPSConsole/SPWebPSConsole.js%>" />
    <SharePoint:CSSRegistration ID="CSSRegistration3" name="<%$SPUrl:~SiteCollection/_layouts/styles/ik.SharePoint2010.SPWebPSConsole/jquery.msgbox.css%>" runat="server"/>
    <SharePoint:CSSRegistration ID="CSSRegistration1" name="<%$SPUrl:~SiteCollection/_layouts/styles/ik.SharePoint2010.SPWebPSConsole/start/jquery-ui-1.8.15.custom.css%>" runat="server"/>
    <SharePoint:CSSRegistration ID="CSSRegistration2" name="<%$SPUrl:~SiteCollection/_layouts/styles/ik.SharePoint2010.SPWebPSConsole/SPWebPSConsole.css%>" runat="server"/>
</asp:content>
<asp:content id="Main" contentplaceholderid="PlaceHolderMain" runat="server">
<SharePoint:FormDigest runat="server"/>
<div title="Starting" id="about" style="display: none">
        <div style="text-align:center">
        <h2>
            Ingo Karstein's<br />
            Web based PowerShell Console</h2>
        <h3>
            (starting)</h3>
            </div>
    </div>
    <div title="<a name='dlgAnchor' id='dlgAnchor'/><table cellspacing='0' cellpadding='0' border='0' width='100%' style='font-size:1.5em'><tr><td colspan='1'>Ingo Karstein's Web based PowerShell Console for SharePoint</td><td rowspan='2' align='right' style='vertical-align:middle;padding-right:20px;font-size:0.6em'>v0.1.0.0</td></tr><tr><td><span style='font-size:0.6em'><a href='http://spwebpsconsole.codeplex.com' target='_blank'>http://spwebpsconsole.codeplex.com</a>&nbsp;|&nbsp;<a href='http://ikarstein.wordpress.com' target='_blank'>http://ikarstein.wordpress.com</a></span></td></tr></table>" id="dlg" style="display: none">

        <div id="outerframe">
            <div>
                <table id="infoTable">
                    <tr>
                        <td width="20px">
                            <asp:Image id="loader" runat="server" style="border: 0px; display: none" ImageUrl="<%$SPUrl:~SiteCollection/_layouts/images/ik.SharePoint2010.SPWebPSConsole/ajax-loader.gif%>" />
                            <asp:Image id="loaderstop" runat="server" style="border: 0px; display: inline" ImageUrl="<%$SPUrl:~SiteCollection/_layouts/images/ik.SharePoint2010.SPWebPSConsole/ajax-loader-stop.gif%>" />
                        </td>
                        <td>
                            &nbsp;|&nbsp;
                        </td>
                        <td>
                            Server: <span style="font-style: italic" id="serverName">&nbsp;</span>
                        </td>
                        <td>
                            &nbsp;|&nbsp;
                        </td>
                        <td>
                            User: <span style="font-style: italic" id="userName">&nbsp;</span>
                        </td>
                        <td>
                            &nbsp;|&nbsp;
                        </td>
                        <td>
                            Session Timeout: <span style="font-style: italic" id="sessionTimeout">&nbsp;</span>
                        </td>
                        <td>
                            &nbsp;|&nbsp;
                        </td>
                        <td >
                            <a href="#" id="rtfLink">
                                Download console as RTF</a>
                        </td>
                        <td>
                            &nbsp;|&nbsp;
                        </td>
                        <td >
                            <a href="#" id="bufLink">
                                Show current buffer</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="console">
            </div>
            <div id="inputField">
                Command input:
                <table class="sectTab" cellpadding="0" cellspacing="0" border="0" width="100%;">
                    <tr>
                        <td class="fields">
                            <textarea style="width: 100%;" rows="5" id="commandText">#$warningpreference="inquire";write-warning "test"
#get-content
#$host.UI.ReadLineAsSecureString()
#clear-host
#get-credential
#read-host
#$host.Ui.RawUI.ReadKey()</textarea>
                        </td>
                        <td class="buttons">
                            <button id="btnSend" style="width: 90px; margin-bottom: 5px;" title="Send">
                                Send</button><br />
                            <button id="btnCancel" style="width: 90px;" title="Cancel">
                                Cancel</button>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="readkey" style="display: none">
                Press a key...
                <table class="sectTab" cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td class="fields">
                            <br />
                            <textarea style="font-size: 3em; overflow: hidden; border: 1px solid #7f7f7f; margin-left: 10px;
                                margin-right: auto; height: 50px; width: 50px;" cols="10" rows="1" id="readkeyField"></textarea>
                            <br />
                            <br />
                        </td>
                        <td class="buttons">
                            <button id="btnCancel2" style="width: 90px; margin-left: 10px;" title="Cancel">
                                Cancel</button>
                        </td>
                    </tr>
                </table>
                <input type="hidden" value="" id="readkeyCorrId" />
            </div>
            <div id="choice" style="display: none">
                <span id="choiceTitle" style="font-weight: bold">Please choose:</span> - <span id="choiceMessage">
                </span>
                <table class="sectTab" cellpadding="0" cellspacing="0" border="0" width="100%;">
                    <tr>
                        <td class="fields">
                            <div id="choiceField">
                                &nbsp;</div>
                        </td>
                        <td class="buttons">
                            <button id="btnSend3" style="width: 90px; margin-bottom: 5px;" title="Send">
                                Send</button><br />
                            <button id="btnCancel3" style="width: 90px;" title="Cancel">
                                Cancel</button>
                        </td>
                    </tr>
                </table>
                <input type="hidden" value="" id="choiceCorrId" />
            </div>
            <div id="credentials" style="display: none">
                <span id="credTitle" style="font-weight: bold">Enter your credentials:</span> -
                <span id="credMessage"></span>
                <table class="sectTab" cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td class="fields">
                            <span style="font-style: italic">User name<span style="font-style: italic" id="credTarget"></span>:</span><br />
                            <input type="text" value="" id="credUsername" style="font-family: Courier New; font-size: 1em;
                                width: 100%" /><br />
                            <span style="font-style: italic">Password:</span><br />
                            <input type="password" value="" id="credPwd" style="font-family: Courier New; font-size: 1em;
                                width: 100%" /><br />
                        </td>
                        <td class="buttons">
                            <button id="btnSend5" style="width: 90px; margin-bottom: 5px;" title="Send">
                                Send</button><br />
                            <button id="btnCancel5" style="width: 90px;" title="Cancel">
                                Cancel</button>
                        </td>
                    </tr>
                </table>
                <input type="hidden" value="" id="credCorrId" />
            </div>
            <div id="lineinput" style="display: none">
                <span id="lineinputTitle" style="font-weight: bold">Enter data:</span> - Description<span
                    id="lineinputMessage"></span>
                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td class="fields">
                            <span id="lineinputName" style="font-style: italic">Field Name:</span><br />
                            <input type="text" value="" id="lineinputField" style="font-family: Courier New;
                                font-size: 1em; width: 100%" />
                        </td>
                        <td class="buttons">
                            <button id="btnSend4" style="width: 90px; margin-bottom: 5px;" title="Send">
                                Send</button><br />
                            <button id="btnCancel4" style="width: 90px;" title="Cancel">
                                Cancel</button>
                        </td>
                    </tr>
                </table>
                <input type="hidden" value="" id="lineinputCorrId" />
            </div>
            <div id="secstr" style="display: none">
                <span style="font-weight: bold">Enter secure string</span>
                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                        <td class="fields">
                            <input type="password" value="" id="secStrInput" style="font-family: Courier New;
                                font-size: 1em; width: 100%" />
                        </td>
                        <td class="buttons">
                            <button id="btnSend6" style="width: 90px; margin-bottom: 5px;" title="Send">
                                Send</button><br />
                            <button id="btnCancel6" style="width: 90px;" title="Cancel">
                                Cancel</button>
                        </td>
                    </tr>
                </table>
                <input type="hidden" value="" id="secstrCorrId" />
            </div>
            <div id="traceFrame">
                <a href="#" onclick="javascript:switchTrace();return false;">Trace log:</a>
                <div id="trace" style="display: none">
                </div>
            </div>
        </div>
    </div>
    <div id="dlgServerError" style="display: none">
        An server error occured!
        
        Press "OK" to reload the site.</div>
    <div id="dlgCommunicationError" style="display: none">
        An communication error occured!
        
        Press "OK" to reload the site.</div>
    <div id="dlgIsRunning" title="PowerShell is running" style="display: none">
        A running PowerShell Pipeline was detected. Maybe an user interaction takes place.
        In this case PowerShell will not come back and you should kill the thread.<br />
        <br />
        Do you want to kill the running Pipeline?
    </div>
    <div id="dlgNewSession" title="Start new session?" style="display: none">
        Your session was terminated while closing the PowerShell Web Console. You could
        create a new server site session by clicking "OK" or reloading this site... Or just
        close the browser...
    </div>
    <div id="dlgSessionTimeout" title="Session timeout" style="display: none">
        Your session timed out. All session data on the server is gone. All pipelines closed, PowerShell shut down.
    </div>
    <div id="dlgCloseSession" title="Close Session?" style="display:none">
        Do you want to close the PowerShell session? - In case of a page refresh choose "No".
    </div>
</asp:content>
<asp:content id="PageTitle" contentplaceholderid="PlaceHolderPageTitle" runat="server">
Ingo Karstein's Web based PowerShell Console for SharePoint
</asp:content>
<asp:content id="PageTitleInTitleArea" contentplaceholderid="PlaceHolderPageTitleInTitleArea"
    runat="server">
Ingo Karstein's Web based PowerShell Console for SharePoint
</asp:content>
